package com.company.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.company.common.annotation.Log;
import com.company.common.core.controller.BaseController;
import com.company.common.core.domain.AjaxResult;
import com.company.common.enums.BusinessType;
import com.company.system.domain.TablePositionlist;
import com.company.system.service.ITablePositionlistService;
import com.company.common.utils.poi.ExcelUtil;
import com.company.common.core.page.TableDataInfo;

/**
 * 职位列Controller
 * 
 * @author ruoyi
 * @date 2022-07-06
 */
@RestController
@RequestMapping("/system/positionlist")
public class TablePositionlistController extends BaseController
{
    @Autowired
    private ITablePositionlistService tablePositionlistService;

    /**
     * 查询职位列列表
     */
    @PreAuthorize("@ss.hasPermi('system:positionlist:list')")
    @GetMapping("/list")
    public TableDataInfo list(TablePositionlist tablePositionlist)
    {
        startPage();
        List<TablePositionlist> list = tablePositionlistService.selectTablePositionlistList(tablePositionlist);
        return getDataTable(list);
    }

    /**
     * 导出职位列列表
     */
    @PreAuthorize("@ss.hasPermi('system:positionlist:export')")
    @Log(title = "职位列", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TablePositionlist tablePositionlist)
    {
        List<TablePositionlist> list = tablePositionlistService.selectTablePositionlistList(tablePositionlist);
        ExcelUtil<TablePositionlist> util = new ExcelUtil<TablePositionlist>(TablePositionlist.class);
        util.exportExcel(response, list, "职位列数据");
    }

    /**
     * 获取职位列详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:positionlist:query')")
    @GetMapping(value = "/{positionid}")
    public AjaxResult getInfo(@PathVariable("positionid") Long positionid)
    {
        return AjaxResult.success(tablePositionlistService.selectTablePositionlistByPositionid(positionid));
    }

    /**
     * 新增职位列
     */
    @PreAuthorize("@ss.hasPermi('system:positionlist:add')")
    @Log(title = "职位列", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TablePositionlist tablePositionlist)
    {
        return toAjax(tablePositionlistService.insertTablePositionlist(tablePositionlist));
    }

    /**
     * 修改职位列
     */
    @PreAuthorize("@ss.hasPermi('system:positionlist:edit')")
    @Log(title = "职位列", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TablePositionlist tablePositionlist)
    {
        return toAjax(tablePositionlistService.updateTablePositionlist(tablePositionlist));
    }

    /**
     * 删除职位列
     */
    @PreAuthorize("@ss.hasPermi('system:positionlist:remove')")
    @Log(title = "职位列", businessType = BusinessType.DELETE)
	@DeleteMapping("/{positionids}")
    public AjaxResult remove(@PathVariable Long[] positionids)
    {
        return toAjax(tablePositionlistService.deleteTablePositionlistByPositionids(positionids));
    }
}
